*** STRATEGIC RIVALRY ANALYSIS
use "C:\replication data-strategic rivalries.dta", clear
heckprob outcome2 directive_dependence directive_powerratio directive_duration directive_biased dependence_power dependence_duration dependence_biased powerratio_duration powerratio_biased biased_duration x1x2x3d x1x2x4 x1x3x4d x2x3x4d x1x2x3x4d lag_mediation_mos bias_mediator med_experience exp_w_med un_mediation mediator_leader disputant_initiate rivalry_duration power_ratio avg_severity dyadic_dependence directive communication, sel(mediation=avg_severity ongoing_dispute power_ratio max_power total_maj_ally lag_directive_mos lag_mediation_mos rivalry_duration dyadic_dependence lag_med) cluster(rivalry)

***** Marginal Effects - Strategic Rivalries
*****
******** POWER RATIO
******
**** Varies values of POWER RATIO
forvalues x2=1/30 {

local x1=0
local x3=1
local x4=0
local ddep=`x1'
local dpow=`x2'
local ddur=`x3'
local dbias=`x4'
local deppow=`x1'*`x2'
local depdur=`x1'*`x3'
local depbias=`x1'*`x4'
local powdur=`x2'*`x3'
local powbias=`x2'*`x4'
local biasdur=`x4'*`x3'
local a123=`x1'*`x2'*`x3'
local a124=`x1'*`x2'*`x4'
local a134=`x1'*`x3'*`x4'
local a234=`x2'*`x3'*`x4'
local a1234=`x1'*`x2'*`x3'*`x4'

local dp=`x1'*`x2'
margins, atmeans at(directive=1 lag_med=0 ongoing_dispute=0 med_experience=1 exp_w_med=0 un_mediation=0 mediator_leader=0 disputant_initiate=0 dependence_power=`deppow' dependence_duration=`depdur' dependence_biased=`depbias' powerratio_duration=`powdur' powerratio_biased=`powbias' biased_duration=`biasdur' x1x2x3d=`a123' x1x2x4=`a124' x1x3x4d=`a134' x2x3x4d=`a234' x1x2x3x4d=`a1234' dyadic_dependence=`x1' power_ratio=`x2' rivalry_duration=`x3' bias_mediator=`x4' directive_dependence=`ddep' directive_powerratio=`dpow' directive_duration=`ddur' directive_biased=`dbias') level(95) predict(pcond) 
}


******** RIVALRY DURATION
******
******
**** Varies values of RIVALRY DURATION
forvalues x3=1(24)361 {

local x1=0
local x2=1.016
local x4=0
local ddep=`x1'
local dpow=`x2'
local ddur=`x3'
local dbias=`x4'
local deppow=`x1'*`x2'
local depdur=`x1'*`x3'
local depbias=`x1'*`x4'
local powdur=`x2'*`x3'
local powbias=`x2'*`x4'
local biasdur=`x4'*`x3'
local a123=`x1'*`x2'*`x3'
local a124=`x1'*`x2'*`x4'
local a134=`x1'*`x3'*`x4'
local a234=`x2'*`x3'*`x4'
local a1234=`x1'*`x2'*`x3'*`x4'

local dp=`x1'*`x2'
margins, atmeans at(directive=1 lag_med=0 ongoing_dispute=0 med_experience=1 exp_w_med=0 un_mediation=0 mediator_leader=0 disputant_initiate=0 dependence_power=`deppow' dependence_duration=`depdur' dependence_biased=`depbias' powerratio_duration=`powdur' powerratio_biased=`powbias' biased_duration=`biasdur' x1x2x3d=`a123' x1x2x4=`a124' x1x3x4d=`a134' x2x3x4d=`a234' x1x2x3x4d=`a1234' dyadic_dependence=`x1' power_ratio=`x2' rivalry_duration=`x3' bias_mediator=`x4' directive_dependence=`ddep' directive_powerratio=`dpow' directive_duration=`ddur' directive_biased=`dbias') level(95) predict(pcond) 
}


******** MEDIATOR BIAS
******
******
*** Sets value for DIRECTIVE variable: Loops through non-directive mediation, then directive mediation

**** Varies values of MEDIATOR BIAS
forvalues x4=0/1 {

local x1=0
local x2=1.016
local x3=1
local ddep=`x1'
local dpow=`x2'
local ddur=`x3'
local dbias=`x4'
local deppow=`x1'*`x2'
local depdur=`x1'*`x3'
local depbias=`x1'*`x4'
local powdur=`x2'*`x3'
local powbias=`x2'*`x4'
local biasdur=`x4'*`x3'
local a123=`x1'*`x2'*`x3'
local a124=`x1'*`x2'*`x4'
local a134=`x1'*`x3'*`x4'
local a234=`x2'*`x3'*`x4'
local a1234=`x1'*`x2'*`x3'*`x4'

local dp=`x1'*`x2'
margins, atmeans at(directive=1 lag_med=0 ongoing_dispute=0 med_experience=1 exp_w_med=0 un_mediation=0 mediator_leader=0 disputant_initiate=0 dependence_power=`deppow' dependence_duration=`depdur' dependence_biased=`depbias' powerratio_duration=`powdur' powerratio_biased=`powbias' biased_duration=`biasdur' x1x2x3d=`a123' x1x2x4=`a124' x1x3x4d=`a134' x2x3x4d=`a234' x1x2x3x4d=`a1234' dyadic_dependence=`x1' power_ratio=`x2' rivalry_duration=`x3' bias_mediator=`x4' directive_dependence=`ddep' directive_powerratio=`dpow' directive_duration=`ddur' directive_biased=`dbias') level(95) predict(pcond) 
}


******** DYADIC DEPENDENCE
******

**** Varies values of DYADIC DEPENDENCE
forvalues x1=0(.005).055 {

local x3=0
local x2=1.016
local x4=0
local ddep=`x1'
local dpow=`x2'
local ddur=`x3'
local dbias=`x4'
local deppow=`x1'*`x2'
local depdur=`x1'*`x3'
local depbias=`x1'*`x4'
local powdur=`x2'*`x3'
local powbias=`x2'*`x4'
local biasdur=`x4'*`x3'
local a123=`x1'*`x2'*`x3'
local a124=`x1'*`x2'*`x4'
local a134=`x1'*`x3'*`x4'
local a234=`x2'*`x3'*`x4'
local a1234=`x1'*`x2'*`x3'*`x4'

local dp=`x1'*`x2'
margins, atmeans at(directive=1 lag_med=0 ongoing_dispute=0 med_experience=1 exp_w_med=0 un_mediation=0 mediator_leader=0 disputant_initiate=0 dependence_power=`deppow' dependence_duration=`depdur' dependence_biased=`depbias' powerratio_duration=`powdur' powerratio_biased=`powbias' biased_duration=`biasdur' x1x2x3d=`a123' x1x2x4=`a124' x1x3x4d=`a134' x2x3x4d=`a234' x1x2x3x4d=`a1234' dyadic_dependence=`x1' power_ratio=`x2' rivalry_duration=`x3' bias_mediator=`x4' directive_dependence=`ddep' directive_powerratio=`dpow' directive_duration=`ddur' directive_biased=`dbias') level(95) predict(pcond) 
}




****************
****************
*** GENERAL RIVALRY ANALYSIS
use "C:\replication data-general rivalries.dta", clear
heckprobit outcome2 directive_dependence directive_powerratio directive_duration directive_biased dependence_power dependence_duration dependence_biased powerratio_duration powerratio_biased biased_duration x1x2x3d x1x2x4 x1x3x4d x2x3x4d x1x2x3x4d lag_mediation_mos bias_mediator med_experience exp_w_med un_mediation mediator_leader disputant_initiate rivalry_duration power_ratio avg_severity dyadic_dependence directive communication, sel(mediation=avg_severity ongoing_dispute power_ratio max_power total_maj_ally lag_directive_mos lag_mediation_mos rivalry_duration dyadic_dependence lag_med) cluster(rivalry)

****** Marginal Effects - General Rivalries
******** POWER RATIO
******
******
**** Varies values of POWER RATIO
forvalues x2=1/30 {

local x1=0
local x3=1
local x4=0
local ddep=`x1'
local dpow=`x2'
local ddur=`x3'
local dbias=`x4'
local deppow=`x1'*`x2'
local depdur=`x1'*`x3'
local depbias=`x1'*`x4'
local powdur=`x2'*`x3'
local powbias=`x2'*`x4'
local biasdur=`x4'*`x3'
local a123=`x1'*`x2'*`x3'
local a124=`x1'*`x2'*`x4'
local a134=`x1'*`x3'*`x4'
local a234=`x2'*`x3'*`x4'
local a1234=`x1'*`x2'*`x3'*`x4'

local dp=`x1'*`x2'
margins, atmeans at(directive=1 lag_med=0 ongoing_dispute=0 med_experience=1 exp_w_med=0 un_mediation=0 mediator_leader=0 disputant_initiate=0 communication=0 dependence_power=`deppow' dependence_duration=`depdur' dependence_biased=`depbias' powerratio_duration=`powdur' powerratio_biased=`powbias' biased_duration=`biasdur' x1x2x3d=`a123' x1x2x4=`a124' x1x3x4d=`a134' x2x3x4d=`a234' x1x2x3x4d=`a1234' dyadic_dependence=`x1' power_ratio=`x2' rivalry_duration=`x3' bias_mediator=`x4' directive_dependence=`ddep' directive_powerratio=`dpow' directive_duration=`ddur' directive_biased=`dbias') level(95) predict(pcond) 
}


******** RIVALRY DURATION
******
******
**** Varies values of RIVALRY DURATION
forvalues x3=1(24)361 {

local x1=0
local x2=1
local x4=0
local ddep=`x1'
local dpow=`x2'
local ddur=`x3'
local dbias=`x4'
local deppow=`x1'*`x2'
local depdur=`x1'*`x3'
local depbias=`x1'*`x4'
local powdur=`x2'*`x3'
local powbias=`x2'*`x4'
local biasdur=`x4'*`x3'
local a123=`x1'*`x2'*`x3'
local a124=`x1'*`x2'*`x4'
local a134=`x1'*`x3'*`x4'
local a234=`x2'*`x3'*`x4'
local a1234=`x1'*`x2'*`x3'*`x4'

local dp=`x1'*`x2'
margins, atmeans at(directive=1 lag_med=0 ongoing_dispute=0 med_experience=1 exp_w_med=0 un_mediation=0 mediator_leader=0 disputant_initiate=0 communication=0 dependence_power=`deppow' dependence_duration=`depdur' dependence_biased=`depbias' powerratio_duration=`powdur' powerratio_biased=`powbias' biased_duration=`biasdur' x1x2x3d=`a123' x1x2x4=`a124' x1x3x4d=`a134' x2x3x4d=`a234' x1x2x3x4d=`a1234' dyadic_dependence=`x1' power_ratio=`x2' rivalry_duration=`x3' bias_mediator=`x4' directive_dependence=`ddep' directive_powerratio=`dpow' directive_duration=`ddur' directive_biased=`dbias') level(95) predict(pcond) 
}



******** MEDIATOR BIAS
******
******
*** Sets value for DIRECTIVE variable: Loops through non-directive mediation, then directive mediation


**** Varies values of MEDIATOR BIAS
forvalues x4=0/1 {

local x1=0
local x2=1
local x3=1
local ddep=`x1'
local dpow=`x2'
local ddur=`x3'
local dbias=`x4'
local deppow=`x1'*`x2'
local depdur=`x1'*`x3'
local depbias=`x1'*`x4'
local powdur=`x2'*`x3'
local powbias=`x2'*`x4'
local biasdur=`x4'*`x3'
local a123=`x1'*`x2'*`x3'
local a124=`x1'*`x2'*`x4'
local a134=`x1'*`x3'*`x4'
local a234=`x2'*`x3'*`x4'
local a1234=`x1'*`x2'*`x3'*`x4'

local dp=`x1'*`x2'
margins, atmeans at(directive=1 lag_med=0 ongoing_dispute=0 med_experience=1 exp_w_med=0 un_mediation=0 mediator_leader=0 disputant_initiate=0 communication=0 dependence_power=`deppow' dependence_duration=`depdur' dependence_biased=`depbias' powerratio_duration=`powdur' powerratio_biased=`powbias' biased_duration=`biasdur' x1x2x3d=`a123' x1x2x4=`a124' x1x3x4d=`a134' x2x3x4d=`a234' x1x2x3x4d=`a1234' dyadic_dependence=`x1' power_ratio=`x2' rivalry_duration=`x3' bias_mediator=`x4' directive_dependence=`ddep' directive_powerratio=`dpow' directive_duration=`ddur' directive_biased=`dbias') level(95) predict(pcond) 
}


******** DYADIC DEPENDENCE
******
******
*** Sets value for DIRECTIVE variable: Loops through non-directive mediation, then directive mediation

**** Varies values of DYADIC DEPENDENCE
forvalues x1=0(.005).055 {

local x3=0
local x2=1
local x4=0
local ddep=`x1'
local dpow=`x2'
local ddur=`x3'
local dbias=`x4'
local deppow=`x1'*`x2'
local depdur=`x1'*`x3'
local depbias=`x1'*`x4'
local powdur=`x2'*`x3'
local powbias=`x2'*`x4'
local biasdur=`x4'*`x3'
local a123=`x1'*`x2'*`x3'
local a124=`x1'*`x2'*`x4'
local a134=`x1'*`x3'*`x4'
local a234=`x2'*`x3'*`x4'
local a1234=`x1'*`x2'*`x3'*`x4'

local dp=`x1'*`x2'
margins, atmeans at(directive=1 lag_med=0 ongoing_dispute=0 med_experience=1 exp_w_med=0 un_mediation=0 mediator_leader=0 disputant_initiate=0 communication=0 dependence_power=`deppow' dependence_duration=`depdur' dependence_biased=`depbias' powerratio_duration=`powdur' powerratio_biased=`powbias' biased_duration=`biasdur' x1x2x3d=`a123' x1x2x4=`a124' x1x3x4d=`a134' x2x3x4d=`a234' x1x2x3x4d=`a1234' dyadic_dependence=`x1' power_ratio=`x2' rivalry_duration=`x3' bias_mediator=`x4' directive_dependence=`ddep' directive_powerratio=`dpow' directive_duration=`ddur' directive_biased=`dbias') level(95) predict(pcond) 
}
